package com.business.corp;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.ConvertUtils;

import com.frame.struts.ActionContext;
import com.frame.struts.BaseBean;
import com.utils.CommUtil;
import com.utils.DateConverter;

public class ZmsbForm extends BaseBean
{
    public ZmsbForm()
    {
    }
    
    static{
        ConvertUtils.register(new DateConverter(), Date.class);
    }

    ZmsbEntity ZmsbEntity = new ZmsbEntity();
    private String oldId="";

    public String addZmsb()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addZmsb()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        NewCorpFactory factory = NewCorpFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        ZmsbEntity.setQyid( qyid );
        ZmsbEntity.setOptdate( new Date() );
        ZmsbEntity.setOptrid( CommUtil.getUserId( request ) );
        ZmsbEntity.setXh( NewCorpFactory.getNextXh( "qy_gsjl_zmsb", qyid ) );
        try
        {
            if( factory.addZmsb( ZmsbEntity ) )
            {
                System.out.println( "Enter addZmsb()" );
                response.sendRedirect( "/corp/queryzmsb.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
        }
        return null;

    }

    public String editZmsb()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addZmsb()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        NewCorpFactory factory = NewCorpFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        ZmsbEntity.setQyid( qyid );
        ZmsbEntity.setOptdate( new Date() );
        ZmsbEntity.setOptrid( CommUtil.getUserId( request ) );
        factory.delZmsb(qyid,ZmsbEntity.getXh());
        try
        {
            if( factory.addZmsb( ZmsbEntity ) )
            {
                System.out.println( "Enter editZmsb()" );
                response.sendRedirect( "/corp/queryzmsb.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        return null;
    }
	
    public String getQyid() {
		return ZmsbEntity.getQyid();
	}
	public void setQyid(String qyid) {
		ZmsbEntity.setQyid(qyid);
	}
	public int getXh() {
		return ZmsbEntity.getXh();
	}
	public void setXh(int xh) {
		ZmsbEntity.setXh(xh);
	}
	public String getMc() {
		return ZmsbEntity.getMc();
	}
	public void setMc(String mc) {
		ZmsbEntity.setMc(mc);
	}
	public String getRdmc() {
		return ZmsbEntity.getRdmc();
	}
	public void setRdmc(String rdmc) {
		ZmsbEntity.setRdmc(rdmc);
	}
	public java.sql.Date getRdsj() {
		return ZmsbEntity.getRdsj();
	}
	public void setRdsj(java.sql.Date rdsj) {
		ZmsbEntity.setRdsj(rdsj);
	}
	public String getRdjg() {
		return ZmsbEntity.getRdjg();
	}
	public void setRdjg(String rdjg) {
		ZmsbEntity.setRdjg(rdjg);
	}
	public String getYxq() {
		return ZmsbEntity.getYxq();
	}
	public void setYxq(String yxq) {
		ZmsbEntity.setYxq(yxq);
	}
	public String getOptrid() {
		return ZmsbEntity.getOptrid();
	}
	public void setOptrid(String optrid) {
		ZmsbEntity.setOptrid(optrid);
	}
	public Date getOptdate() {
		return ZmsbEntity.getOptdate();
	}
	public void setOptdate(Date optdate) {
		ZmsbEntity.setOptdate(optdate);
	}
	public String getRecstate() {
		return ZmsbEntity.getRecstate();
	}
	public void setRecstate(String recstate) {
		ZmsbEntity.setRecstate(recstate);
	}
	public String getRemark() {
		return ZmsbEntity.getRemark();
	}
	public void setRemark(String remark) {
		ZmsbEntity.setRemark(remark);
	}
   

}
